<template>
	<view class="">
		<u-navbar :border-bottom="false" title-color="#333" title-bold title="我的法海" title-size="36"></u-navbar>
		<view class="tab-div">
			<view class="zhishi">
				<view class="flex flex_end ">
					<view class="gl-btn" @click="delshow=!delshow">
						<u-icon name="list-dot" color="#666" size="28"></u-icon>
						管理
					</view>
				</view>

				<view class="pro-div flex flex_wrap flex_sb">
					<view class="pro-item" v-for="(item,index) in fahaiList" :key="index" @click="tidetail(item)">
						<view class="pro-img">
							<image v-if="item.images && item.images.length>0" class="pro-item-img" :src="item.images[0]"
								mode="aspectFill"></image>
							<image v-if="item.video" class="pro-item-bf" src="../../../../static/img/home/bofang-icon.png" mode=""></image>

							<view class="zhezhao flex flex_cen" v-if="delshow">
								<view class="gl-i" @click.stop="edit(item)">
									<image class="gl-icon" src="../../../static/img/lawyerVersion/bj-2.png" mode="">
									</image>
								</view>
								<view class="gl-i u-m-l-32" @click.stop="del(item)">
									<image class="gl-icon" src="../../../static/img/lawyerVersion/del-2.png" mode="">
									</image>
								</view>
							</view>
						</view>
						<view class="u-m-t-12">
							<view class="line_1 textitl">
								{{item.title}}
							</view>
						</view>


					</view>
				</view>
			</view>
		</view>
		<view class="" style="width: 100%;height: 170rpx;"></view>
		<view class="btn-bo">
			<button class="btn_login_btn" @click="add">
				添加
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				delshow: false,
				fahaiList: [],
				
				total:0,
				pageNum:1,
				pageSize:10,
			}
		},
		onReachBottom() {
			if (this.pageNum * this.pageSize > this.total) {
				// uni.hideNavigationBarLoading();
			} else {
				this.pageNum++;
				this.gefahai()
			}
		},
		onShow() {
			this.pageNum = 1
			this.gefahai()
		},
		methods: {
			gefahai() {
				this.$api({
					url: '/lawyer/my_getSeaList',
					method: 'get',
					data: {
						page:this.pageNum,
						limit:this.pageSize,
						token: uni.getStorageSync("token"),
						lawyer_id: 0 //律师ID，所有数据传-1，自己数据传0，其它律师数据传具体ID
					},
				}).then(res => {
					if (res.code == 1) {
						// this.fahaiList = res.data.list
						
						this.total=res.data.count
						let data = res.data.list
						if (this.pageNum == 1) {
							this.fahaiList = data
						} else {
							this.fahaiList = [...this.fahaiList, ...data]
						}
					}
				})
			},
			del(e) {
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认删除吗',
					success: function(res) {
						if (res.confirm) {
							that.$api({
								url: '/lawyer/delSeaInfo',
								method: 'post',
								data: {
									token: uni.getStorageSync("token"),
									ids: e.id
								},
							}).then(res => {
								if (res.code == 1) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									that.gefahai()
								}
							})
						}
					}
				});
			},
			tidetail(e) {
				uni.navigateTo({
					url: "/pages/index/fahaiDetail?id=" + e.id
				})
			},
			add() {
				uni.navigateTo({
					url: "/subPackageA/pages/lawyerVersion/mine/addfahai"
				})
			},
			edit(item){
				uni.navigateTo({
					url: "/subPackageA/pages/lawyerVersion/mine/addfahai?id="+item.id
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.linhe48 {
		line-height: 40rpx;
	}

	.del-icon {
		width: 40rpx;
		height: 40rpx;
	}

	.btn-bo {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0rpx -2rpx 8rpx 2rpx rgba(0, 0, 0, 0.14);
		padding-top: 14rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 9;

		.btn_login_btn {
			width: 686rpx;
			height: 90rpx;
			background: linear-gradient(180deg, #FA2D2D 0%, #F40000 100%);
			border-radius: 46rpx 46rpx 46rpx 46rpx;
			// margin-top: 116rpx;
			font-size: 36rpx;
			color: #fff;
			line-height: 90rpx;
			margin-left: 32rpx;
			text-align: center;
			font-weight: bold;
		}
	}

	.gl-btn {
		width: 130rpx;
		height: 48rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		border: 2rpx solid #605F6A;
		text-align: center;
		line-height: 48rpx;
	}

	.tab-div {
		width: 750rpx;
		// height: 672rpx;
		padding: 32rpx;
		// background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin: 0 auto;
	}

	.pro-div {
		.pro-item {
			margin-top: 24rpx;




			.pro-img {
				position: relative;
				width: 332rpx;
				height: 440rpx;
				border-radius: 8rpx;
				background-color: #eee;

				.zhezhao {
					position: absolute;
					width: 332rpx;
					height: 440rpx;
					border-radius: 8rpx;
					top: 0;
					left: 0;
					background-color: rgba(0, 0, 0, 0.5);

					.gl-i {
						width: 64rpx;
						height: 64rpx;
						background: #000000;
						border-radius: 50%;
						display: flex;
						align-items: center;
						justify-content: center;

						.gl-icon {
							width: 32rpx;
							height: 32rpx;
						}
					}
				}

				.pro-item-img {
					position: absolute;
					top: 0;
					left: 0;
					width: 332rpx;
					height: 440rpx;
					border-radius: 8rpx;
				}

				.pro-item-bf {
					position: absolute;
					bottom: 20rpx;
					right: 20rpx;
					width: 40rpx;
					height: 40rpx;
				}
			}

			.textitl {
				width: 332rpx;
				font-weight: bold;
				font-size: 28rpx;
				color: #333333;
			}

			.headimg {
				width: 36rpx;
				height: 36rpx;
				border-radius: 50%;
			}
		}
	}
</style>